package hellohdfs;

import java.io.FileInputStream;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;

public class Test1 {
   //导入 E:\大数据\hadoop-2.7.3\share\hadoop\common\hadoop-common-2.7.3.jar
	//导入E:\大数据\hadoop-2.7.3\share\hadoop\common\lib所有包
	//导入E:\大数据\hadoop-2.7.3\share\hadoop\hdfs\hadoop-hdfs-2.7.3.jar
	public static void main(String[] args) throws Exception {
		
		/*URL url = new URL("http://www.baidu.com");
		InputStream inputStream = url.openStream();
		IOUtils.copyBytes(inputStream, System.out, 4096,true);
		*/
/*		URL.setURLStreamHandlerFactory( new FsUrlStreamHandlerFactory() );
		URL url = new URL("hdfs://192.168.128.129:9000/hello.txt");
		InputStream inputStream = url.openStream();
		IOUtils.copyBytes(inputStream, System.out, 4096,true);*/
		Configuration conf=new Configuration();
		conf.set("fs.defaultFS", "hdfs://192.168.128.129:9000");
		FileSystem fileSystem = FileSystem.get(conf);
		
/*		boolean result = fileSystem.mkdirs(new Path("/abc"));
		System.out.println("创建目录:"+result);*/
		FSDataOutputStream fs = fileSystem.create(new Path("/test.data"),true);
		FileInputStream fileInputStream=new FileInputStream("c:/a.html");
		IOUtils.copyBytes(fileInputStream, fs, 4096, true);
	}
	

}
